<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>机构管理</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <link rel="stylesheet" href="${ctx}/css/ui/system/member/member_list.css">
    <%@include file="../../include/commonFile.jsp" %>
</head><body>
<!--头部-->
<%@include file="../../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <form class="layui-form" action="${ctx}/system/member/personList.do" id="myForm" method="post">
                <input type="hidden" name="pageNo" id="pageNo" value="${page.page}"/>
                <div class="f-search-bar">
                    <div class="search-container">

                        <ul class="search-form-content">
                            <li class="form-item-inline"><label class="search-form-lable">昵称</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="realname" autocomplete="off" class="layui-input"
                                           value="${member.realname}" placeholder="请输入查询昵称">
                                </div>
                            </li>
                            <li class="form-item-inline"><label class="search-form-lable">手机号</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="mobile" autocomplete="off" class="layui-input"
                                           value="${member.mobile}" placeholder="请输入查询手机号">
                                </div>
                            </li>
                            <%--<li class="form-item-inline"><label class="search-form-lable">状态</label>
                                <div class="layui-input-inline">
                                    <select name="newStatus">
                                        <option value="">全部</option>
                                        <option value="1" ${status == "1" ? 'selected="selected"' : ''}>已认证</option>
                                        <option value="0,2,3" ${status == "0,2,3" ? 'selected="selected"' : ''}>未认证
                                        </option>
                                    </select>
                                </div>
                            </li>--%>
                            <li class="form-item-inline">
                                <div class="sub-btns">
                                    <a class="layui-btn layui-btn-danger" href="javascript:submitFunction('#myForm')">查询</a>
                                    <a class="layui-btn layui-btn-normal" href="javascript:resetFunction('#myForm')">重置</a>
                                </div>
                            </li>
                        </ul>
                        <ul class="search-form-content">

                        </ul>
                        <ul class="search-form-content">
                            <li class="form-item"><label class="search-form-lable">注册时间</label>
                                <div class="check-btn-inner" id="timeType">
                                    <a id="all" href="javascript:void(0);"
                                       onclick="setTimeType($(this),0,'#myForm')" ${empty input.timeType || input.timeType == 0 ? 'class="active"' : ''}>全部</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),1,'#myForm')" ${input.timeType == 1 ? 'class="active"' : ''}>今天</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),2,'#myForm')" ${input.timeType == 2 ? 'class="active"' : ''}>本周内</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),3,'#myForm')" ${input.timeType == 3 ? 'class="active"' : ''}>本月内</a>
                                    <input type="hidden" name="timeType" value="${input.timeType}"/>
                                </div>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createStart"
                                               value="${input.createStart}" placeholder="开始日">
                                    </div>
                                    -
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createEnd"
                                               value="${input.createEnd}" placeholder="截止日">
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </form>
            <div class="list-content">
                <div class="cl">
                    <table class="layui-table">
                        <colgroup>
                            <col>
                            <col>
                            <col>
                            <col>
                            <%--<col width="100">--%>
                            <col>
                        </colgroup>
                        <thead>
                        <tr>
                            <th>昵称</th>
                            <th>用户名</th>
                            <th>手机号</th>
                            <th>注册时间</th>
                            <%--<th>状态</th>--%>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach var="member" items="${members}">
                            <tr>
                                <td class="table-member"
                                    onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${member.id}','400px','470px')">
                                    <div class="member-cell">
                                        <div class="member-logo common-img" >
                                            <img src="${member.logo}" alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                        </div>
                                        <div class="member-name ellipsis-1">
                                            <c:if test="${member.type == 2}">
                                                <a class="blue" title="${member.company}" href="javascript:void(0);">${member.company}</a>
                                            </c:if>
                                            <c:if test="${member.type == 1 or empty member.company}">
                                            <a class="blue" title="${member.realname}" href="javascript:void(0);">${member.realname}</a>
                                            </c:if>
                                        </div>
                                    </div>
                                </td>
                                <td>${member.username}</td>
                                <td>${member.mobile}</td>
                                <td><fmt:formatDate value="${member.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                                <%--<td>
                                    <c:choose>
                                        <c:when test="${member.userStatus == 0 || member.userStatus == 2 || member.userStatus == 3}">
                                            未认证
                                        </c:when>
                                        <c:when test="${member.userStatus == 1}">
                                            已认证
                                        </c:when>
                                    </c:choose>
                                </td>--%>
                                <td class="tb-opts">
                                    <div class="comm-opts">
                                        <a href="${ctx}/system/member/resetPwdForm.do?memberId=${member.id}" target="_self">修改密码</a>
                                        <%--<a href="${ctx}/system/member/personForm.do?id=${member.id}" target="_self">编辑</a>
                                        <c:if test="${member.userStatus == 0 || member.userStatus == 3}">
                                            <a class="green" href="javascript:verify('确认要通过吗？','1','${member.id}')">通过</a>
                                            <a class="red" href="javascript:verify('确认要拒绝吗？','2','${member.id}')">拒绝</a>
                                        </c:if>
                                        <c:choose>
                                            <c:when test="${member.userStatus == 1 }">
                                                <c:choose>
                                                    <c:when test="${member.isExpert == 1 }">
                                                        <a href="javascript:expertSwitch('${member.id}', 0)">取消达人</a>
                                                        <a href="${ctx}/dynamic/dynamic/helpPublish.do?memberId=${member.id}">代发动态</a>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <a href="javascript:expertSwitch('${member.id}', 1)">设为达人</a>
                                                    </c:otherwise>
                                                </c:choose>
                                            </c:when>
                                        </c:choose>--%>
                                    </div>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
            </div>
            <div id="page_content" class="page-container"></div>
        </div><!--底部-->
        <%@include file="../../include/footer.jsp" %>
    </section>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>

<script type="text/javascript">

    <%--showActive('${input.createStart}', '${input.createEnd}', '#timeType');--%>

    $(function () {
        //加载分页
        loadPageNew({elem: 'page_content', totalCount: '${page.totalCount}', limit: '${page.limit}', page: '${page.page}'});
        layui.use(['laydate'], function () {
            var laydate = layui.laydate;
            // 查询发布日期
            var start = {
                elem: 'input[name=createStart]'
            };

            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);
        });
    })
    function openDialog(title, url, width, height, target) {
        layer.open({
            type: 2,
            area: [width, height],
            title: title,
            maxmin: true, //开启最大化最小化按钮
            content: url,
            btn: ['确定', '关闭'],
            yes: function (index, layero) {
                var body = layer.getChildFrame('body', index);
                var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                var inputForm = body.find('#inputForm');
                var top_iframe;
                if (target) {
                    top_iframe = target;//如果指定了iframe，则在改frame中跳转
                } else {
                    top_iframe = '_parent';//获取当前active的tab的iframe
                }
                inputForm.attr("target", top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示

                if (iframeWin.contentWindow.doSubmit()) {
                    setTimeout(function () {
                        top.layer.close(index);
                    }, 100);//延时0.1秒，对应360 7.1版本bug

                    setTimeout(function () {
                        window.location.reload();
                    }, 200);
                }

            },
            cancel: function (index) {
            }
        });
    }


    function verify(content, status, targetId) {
        layer.confirm(content, {icon: 3, title: '系统提示'}, function (index) {
            $.post('${ctx}/system/member/verify.do', {id: targetId, userStatus: status}, function (res) {
                if (res.success) {
                    util.layerMsgSuccess("操作成功", function () {
                        location.reload();
                    });
                } else {
                    util.layerMsgError("操作失败")
                }
            });
        });
    }

    function adminSwitch(id, isAdmin) {
        var content;
        if (isAdmin == 1) {
            content = '确认设为管理员？';
        } else if (isAdmin == 0) {
            content = '确认取消管理员？';
        }
        layer.confirm(content, {icon: 3, title: '系统提示'}, function (index) {
            $.post('${ctx}/system/member/setAdmin.do', {id: id, isAdmin: isAdmin}, function (res) {
                if (res.success) {
                    util.layerMsgSuccess("操作成功", function () {
                        location.reload();
                    });
                } else {
                    util.layerMsgError("操作失败")
                }
            });
        });
    }

    function expertSwitch(id, isExpert) {
        var content;
        if (isExpert == 1) {
            content = '确认设为达人？';
        } else if (isExpert == 0) {
            content = '确认取消达人？';
        }
        layer.confirm(content, {icon: 3, title: '系统提示'}, function (index) {
            $.post('${ctx}/system/member/setExpert.do', {id: id, isExpert: isExpert}, function (res) {
                if (res.success) {
                    util.layerMsgSuccess("操作成功", function () {
                        location.reload();
                    });
                } else {
                    util.layerMsgError("操作失败")
                }
            });
        });
    }
</script>
<script type="text/javascript">
    txz.initHeader({
        nav:[{
            name: '联合发起人',
            curr: true
        }],
        info:'<span class="f12">共<b id="totalCount">${page.totalCount}</b>条记录</span>',
    });
</script>
</body>
</html>